package com.haelth.models.medicinedata;

import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

public class Medicine implements Runnable {
	private String id;
	private String enName;
	private String cName;
	private String Comapny;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getEnName() {
		return enName;
	}

	public void setEnName(String enName) {
		this.enName = enName;
	}

	public String getcName() {
		return cName;
	}

	public void setcName(String cName) {
		this.cName = cName;
	}

	public String getComapny() {
		return Comapny;
	}

	public void setComapny(String comapny) {
		Comapny = comapny;
	}

	@Override
	public String toString() {
		return "Medicine [id=" + id + ", enName=" + enName + ", cName=" + cName
				+ ", Comapny=" + Comapny + "]";
	}

	public void run()  {
		URL url;
		Document doc;
		try {
			url = new URL("http://www.nhi.gov.tw/Query/query1_list.aspx?Q1ID="
					+ id);
			doc = Jsoup.parse(url, 10000000);
			Element newsHeadline = doc
					.getElementById("gvQuery1Data_ctl02_lblNameChinese");
			this.cName = newsHeadline.text();
			//System.out.println(newsHeadline.text());
		} catch (IOException e) {
			e.printStackTrace();
		} 

	}
}
